-
Notifications
You must be signed in to change notification settings - Fork 698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make bitfield unit allocation fallible #1141
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me, thanks for the fix! :)
@@ -466,7 +466,7 @@ impl FieldMethods for RawField { | |||
fn raw_fields_to_fields_and_bitfield_units<I>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add to the doc comment when do we return errors?
src/ir/comp.rs
Outdated
@@ -1046,6 +1065,7 @@ impl CompInfo { | |||
/// Get this type's set of fields. | |||
pub fn fields(&self) -> &[Field] { | |||
match self.fields { | |||
CompFields::ErrorComputingBitfieldUnits => &[][..], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think the [..]
is not needed.
src/ir/comp.rs
Outdated
@@ -1558,6 +1578,10 @@ impl IsOpaque for CompInfo { | |||
return true | |||
} | |||
|
|||
if let CompFields::ErrorComputingBitfieldUnits = self.fields { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note when can this happen? (here or somewhere else where it may make sense)
Instead of panicking when we see a bitfield that does not have a layout, return an error up the stack. If we get an error when allocating bitfields into units, then make the whole struct opaque. Fixes rust-lang#1140
37cf177
to
43b88c5
Compare
Thanks for the review! Good calls on the comments, I've updated the commit. @bors-servo r+ |
📌 Commit 43b88c5 has been approved by |
@bors-servo r- |
@bors-servo r=emilio d'oh |
📌 Commit 43b88c5 has been approved by |
☀️ Test successful - status-travis |
Instead of panicking when we see a bitfield that does not have a layout, return an error up the stack. If we get an error when allocating bitfields into units, then make the whole struct opaque.
Fixes #1140
r? @pepyakin or @emilio